package Desort;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class SecondIndexDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //定义输入输出路径
        args=new String[]{"E:\\test\\temp\\name_data\\","E:\\test\\temp\\name_data2"};

        //创建配置文件
        Configuration conf = new Configuration();
        //创建Job任务
        Job job = Job.getInstance(conf);

        //设置Driver反射
        job.setJarByClass(SecondIndexDriver.class);

        //设置Mapper反射
        job.setMapperClass(SecondIndexMapper.class);
        //设置Mapper的输出（key,value）类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);

        //设置Reducer反射
        job.setReducerClass(SecondIndexReducer.class);
        //设置Reducer的输出（key,value）类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        //指定输入输出路径
        FileInputFormat.setInputPaths(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));

        //提交job任务到yarn执行
        boolean isSuccess = job.waitForCompletion(true);
        System.exit(isSuccess?0:-1);
    }
}
